import http from '@/utils/request';

interface MyRequestOptions {
	url : string;
	method : 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
	data ?: Record<string, unknown>;
	ticket ?: number;
}
/**
 * @description: 查询备件列表
 */
export async function getSelectSpareList(data) : Promise<any> {
	const options : MyRequestOptions = {
		url: '/equpManager/selectSpareList',
		method: 'GET',
		data: data,
		ticket: 1, // 为1带satoken
	};
	try {
		const response = await http.globalRequest(options);
		if (response.code === 2000) {
			return response.data;
		} else { throw response.msg }
	} catch (error) {
		throw error;
	}
}
/**
 * @description: 查询设备管理信息
 */
export async function getSelectList(data) : Promise<any> {
	const options : MyRequestOptions = {
		url: '/equpManager/selectList',
		method: 'POST',
		data: data,
		ticket: 1, // 为1带satoken
	};
	try {
		const response = await http.globalRequest(options);
		if (response.code === 2000) {
			return response.data;
		} else { throw response.msg }
	} catch (error) {
		throw error;
	}
}
/**
 * @description: 故障处理
 */
export async function submitInfo(data) : Promise<any> {
	const options : MyRequestOptions = {
		url: '/equpManager/submit',
		method: 'POST',
		data: data,
		ticket: 1, // 为1带satoken
	};
	try {
		const response = await http.globalRequest(options);
		if (response.code === 2000) {
			return response;
		} else { throw response.msg }
	} catch (error) {
		throw error;
	}
}
/**
 * @description: 根据设备条码查询故障信息
 */
export async function getEqupManageByBarcode(data) : Promise<any> {
	const options : MyRequestOptions = {
		url: '/equpManager/queryEqupManageByBarcode',
		method: 'GET',
		data: data,
		ticket: 1, // 为1带satoken
	};
	try {
		const response = await http.globalRequest(options);
		if (response.code === 2000) {
			return response.data;
		} else { throw response.msg }
	} catch (error) {
		throw error;
	}
}
/**
 * @description: 故障确认
 */
export async function setSure(data) : Promise<any> {
	const options : MyRequestOptions = {
		url: '/equpManager/sure',
		method: 'POST',
		data: data,
		ticket: 1, // 为1带satoken
	};
	try {
		const response = await http.globalRequest(options);
		if (response.code === 2000) {
			return response;
		} else { throw response.msg }
	} catch (error) {
		throw error;
	}
}
/**
 * @description: 备件申领
 */
export async function setSpareApply(data) : Promise<any> {
	const options : MyRequestOptions = {
		url: '/equpManager/addSpareApply',
		method: 'POST',
		data: data,
		ticket: 1, // 为1带satoken
	};
	try {
		const response = await http.globalRequest(options);
		if (response.code === 2000) {
			return response;
		} else { throw response.msg }
	} catch (error) {
		throw error;
	}
}
/**
 * @description: 设备主管列表
 */
export async function getManagerList(data) : Promise<any> {
	const options : MyRequestOptions = {
		url: '/equpManager/selectManager',
		method: 'GET',
		data: data,
		ticket: 1, // 为1带satoken
	};
	try {
		const response = await http.globalRequest(options);
		if (response.code === 2000) {
			return response.data;
		} else { throw response.msg }
	} catch (error) {
		throw error;
	}
}
/**
 * @description: 设备主管列表
 */
export async function setManagerSure(data) : Promise<any> {
	const options : MyRequestOptions = {
		url: '/equpManager/managerSure',
		method: 'POST',
		data: data,
		ticket: 1, // 为1带satoken
	};
	try {
		const response = await http.globalRequest(options);
		if (response.code === 2000) {
			return response;
		} else { throw response.msg }
	} catch (error) {
		throw error;
	}
}
/**
 * @description: 上传图片
 */
export async function upLoadEqupManageImage(data) : Promise<any> {
	const options : MyRequestOptions = {
		url: '/equpManager/upLoadEqupManageImage',
		method: 'POST',
		data: data,
		ticket: 1, // 为1带satoken
	};
	try {
		const response = await http.globalRequest(options);
		if (response.code === 2000) {
			return response;
		} else { throw response.msg }
	} catch (error) {
		throw error;
	}
}
/**
 * @description: 删除图片
 */
export async function deleteEqupManageImage(data) : Promise<any> {
	const options : MyRequestOptions = {
		url: '/equpManager/deleteEqupManageImage',
		method: 'GET',
		data: data,
		ticket: 1, // 为1带satoken
	};
	try {
		const response = await http.globalRequest(options);
		if (response.code === 2000) {
			return response;
		} else { throw response.msg }
	} catch (error) {
		throw error;
	}
}
/**
 * @description: 设备故障登记
 */
export async function addFault(data) : Promise<any> {
	const options : MyRequestOptions = {
		url: '/equpManager/add',
		method: 'POST',
		data: data,
		ticket: 1, // 为1带satoken
	};
	try {
		const response = await http.globalRequest(options);
		if (response.code === 2000) {
			return response;
		} else { throw response.msg }
	} catch (error) {
		throw error;
	}
}
/**
 * @description: 员工信息查询
 */
export async function queryEmpInfo(data) : Promise<any> {
	const options : MyRequestOptions = {
		url: '/equpManager/queryEmpInfo',
		method: 'POST',
		data: data,
		ticket: 1, // 为1带satoken
	};
	try {
		const response = await http.globalRequest(options);
		if (response.code === 2000) {
			return response.data;
		} else { throw response.msg }
	} catch (error) {
		throw error;
	}
}
/**
 * @description: 参与人查询
 */
export async function getPartNameList(data) : Promise<any> {
	const options : MyRequestOptions = {
		url: '/equpManager/getPartNameList',
		method: 'GET',
		data: data,
		ticket: 1, // 为1带satoken
	};
	try {
		const response = await http.globalRequest(options);
		if (response.code === 2000) {
			return response.data;
		} else { throw response.msg }
	} catch (error) {
		throw error;
	}
}